<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	小程序粉丝管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	//搜索
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>2);
	if($_RQ['nickname']){
		$params['nickname like']='%'.trim($_RQ['nickname']).'%';
		$return['params']['nickname']=$_RQ['nickname'];
	}
	if($_RQ['wxapp_id']){
		$params['wxgid']=intval($_RQ['wxapp_id']);
		$return['params']['wxapp_id']=$_RQ['wxapp_id'];
	}
	$fields=array('id','avatar','nickname','updatetime');
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$total='';
	$list=pdo_getslice('core_fans',$params,array($pindex,$psize),$total,$fields);
	if($list){
		foreach($list as &$row){
			$row['avatar']=$row['avatar'];
			$row['updatetime']=date('20y/m/d H:i:s',$row['updatetime']);
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['wxapps']=pdo_getall('core_account_wxapp',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			'0'=>array('op'=>'list','title'=>'粉丝管理列表'),
		),
		'list'=>array('data'=>'list','delall'=>false,'del_one'=>false,'edit'=>false,'list'=>array(
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'nickname','title'=>'昵称','type'=>'string'),
		),'action'=>array(
			array('type'=>'href','op'=>'detail','title'=>'详情'),
		)),
		'search_one'=>array('name'=>'nickname','add'=>false,'select'=>true,'select_name'=>'wxapp_id','select_title'=>'请选择来源小程序','options'=>'wxapps')
	);
	$return['htmls']=$htmls;
	//exi($return['params']['wxapp_id'],'error');
	exi($return);
}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('core_fans',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	}else{
		$item=array();
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'look',
		'desc'=>'粉丝详情',
		'tabs'=>array(
			array('op'=>'list','title'=>'粉丝列表'),
			array('op'=>'detail','title'=>'粉丝详情'),
		),
		'look'=>array(
			array('type'=>'string','title'=>'头像','name'=>'avatar', 'help'=>'' ),
			array('type'=>'string','title'=>'粉丝编号','name'=>'openid', 'help'=>'' ),
			array('type'=>'string','title'=>'关联会员ID','name'=>'mid','help'=>'' ),
			array('type'=>'string','title'=>'关注/取消关注时间','name'=>'shijian' , 'help'=>''),
			array('type'=>'string','title'=>'昵称','name'=>'nickname'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
?>